import js from '@eslint/js'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import pluginVue from 'eslint-plugin-vue'

import stylistic from '@stylistic/eslint-plugin'
import importPlugin from 'eslint-plugin-import'
import nodePlugin from 'eslint-plugin-node'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'

import { defineConfig, globalIgnores } from 'eslint/config'

export default defineConfig([
  {
    files: ['**/*.{js,mjs,cjs,ts,mts,cts,vue}'],
    plugins: {
      js,
      import: importPlugin,
      node: nodePlugin,
      '@stylistic': stylistic,
    },
    extends: ['js/recommended'],
    languageOptions: { globals: globals.browser },
  },
  {
    rules: {
      '@stylistic/no-multiple-empty-lines': ['warn', { max: 1 }],
      'no-var': 'error',
      'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
      'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    },
  },
  tseslint.configs.recommended,
  pluginVue.configs['flat/essential'],
  {
    files: ['**/*.vue'],
    languageOptions: { parserOptions: { parser: tseslint.parser } },
  },
  eslintPluginPrettierRecommended,
  globalIgnores(['/node_module', '/dist']), //排除目录
])
